/*
 * JsonProtocolUtil<br/>
 * 包含类名列表<br/>
 * 版本信息<br/>
 * date 2016/12/12 10:55<br/>
 * CopyRight IFLYTEK Co.,Ltd. All Rights Reserved.
 */
package com.iflytek.speech.mvw;

import android.os.SystemClock;
import android.text.TextUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * JsonProtocolUtil
 *
 * @author ydwang3<br/>
 *         description: ${}<br/>
 *         create: 2016/12/12 10:55<br/>
 *         <p>
 *         change by ydwang3, 2016/12/12 10:55, reason: ${}
 */
public class JsonProtocolUtil {

    public static final String TAG = JsonProtocolUtil.class.getSimpleName();
    private static final String PROPERTY_DIMENSION = "dimension";
    private static final String PROPERTY_KEYWORD = "Keywords";
    private static final String PROPERTY_NKEYWORD = "nKeyword";

    public static String convertIvwKeyword(List<String> names) {
        if (names == null || names.isEmpty()) {
            return null;
        }

        JSONObject objRoot = new JSONObject();
        JSONArray objArr = new JSONArray();

        try {
            for (int i = 0; i < names.size(); i++) {
                JSONObject objWord1 = new JSONObject();
                objWord1.put("KeyWordId", i);
                objWord1.put("KeyWord", names.get(i));
                objArr.put(objWord1);
            }
        } catch (JSONException e) {

        }
        try {
            objRoot.put(PROPERTY_KEYWORD, objArr);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return objRoot.toString();
    }

    private static int setHolderLevelByWords(String word) {
        if (word != null && word.length() >= 5) {
            return 1100;
        } else if (word != null && word.length() >= 3) {
            return 1200;
        }
        return 0;
    }
}
 